package com.zb_study.StringBuffer.Exercise;

public class StringBufferExercise {
    public static void main(String[] args) {

        String price = "2312312.21";
        StringBuffer stringBuffer = new StringBuffer(price);
//        int i = stringBuffer.lastIndexOf(".");
//        stringBuffer = stringBuffer.insert(i-3,",");
//        System.out.println(stringBuffer);

        for (int i = stringBuffer.lastIndexOf(".") - 3; i > 0; i -= 3) {
            stringBuffer = stringBuffer.insert(i, ",");
        }
        System.out.println(stringBuffer);
    }
}
